//
//  RootBarViewController.m
//  SoupApp
//
//  Created by pro2 on 2018/11/5.
//  Copyright © 2018 pro2. All rights reserved.
//

#import "RootBarViewController.h"
#import "RootNavViewController.h"
#import "HomeController.h"
#import "FundController.h"
#import "MineController.h"

@interface RootBarViewController ()

@end

@implementation RootBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    //登录状态赋值
    CLIENT.isLogin = [UserDefaults getAutoLogin];
    
    [self configTabbar];
}

- (void)configTabbar
{
    HomeController * homeController = [[HomeController alloc] initWithNibName:@"HomeController" bundle:nil];
    UIViewController * homeNavigationController = [[RootNavViewController alloc]
                                                   initWithRootViewController:homeController];
    homeNavigationController.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"" image:[UIImage imageNamed:@"首页"] selectedImage:[UIImage imageNamed:@"首页选中"]];
    homeNavigationController.tabBarItem.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);
    
    FundController * fundController = [[FundController alloc] initWithNibName:@"FundController" bundle:nil];
    UIViewController * fundNavigationController = [[RootNavViewController alloc]
                                                   initWithRootViewController:fundController];
    fundNavigationController.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"" image:[UIImage imageNamed:@"发现"] selectedImage:[UIImage imageNamed:@"发现选中"]];
    fundNavigationController.tabBarItem.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);
    
    MineController * mineViewController = [[MineController alloc] initWithNibName:@"MineController" bundle:nil];
    UIViewController * mineNavigationController = [[RootNavViewController alloc]
                                                   initWithRootViewController:mineViewController];
    mineNavigationController.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"" image:[UIImage imageNamed:@"我的"] selectedImage:[UIImage imageNamed:@"我的选中"]];
    mineNavigationController.tabBarItem.imageInsets = UIEdgeInsetsMake(5, 0, -5, 0);
    
    [UITabBar appearance].translucent = NO;
    [[UITabBar appearance] setBarTintColor:[UIColor colorWithRed:250/255.0 green:250/255.0 blue:250/255.0 alpha:0.9]];
    
    self.tabBar.clipsToBounds = YES;
    
    self.viewControllers = @[homeNavigationController,
                                              fundNavigationController,
                                              mineNavigationController
                                              ];
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
